﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Runtime.Remoting.Messaging;

namespace DomainInfoLib
{
    delegate void DoworkHandle();

    public class Digger
    {



        public Digger()
        {
            Exc = new ExcuterQueue(); 
        }

        public int ThreadCount { get; private set; }

        public void SetThreadCount(int Count)
        {
           
            ThreadCount=Count;
        }


        public bool Cancel()
        {
            try
            {

                Exc.Stop();
                
                return true;
            }
            catch (Exception ex)
            {
                
                throw ex;
            }

        }

        IExcuter Exc;

        public void dig(QueryGroup _QueryGroup)
        {
            Exc = new ExcuterQueue();
            Exc.SetThreadCount(ThreadCount);
            Exc.AnItemDone += new DoneHandle(item_Done);
            Exc.ExcAll( _QueryGroup.Items);
        }

        private void item_Done(QueryItem item)
        {
            DoneOne(item);
        }

        public event GottenRegisteInfoHandle DoneOne;

    }
}
